package com.openbravo.pos.panels;

import com.attilax.cc.datex;
import com.attilax.formatter.SqlFormatter;
import com.attilax.lang.text.strUtil;
import com.attilax.time.timeUtil;
import com.attilax.util.DateUtil;
import com.openbravo.basic.BasicException;
import com.openbravo.data.gui.MessageInf;
import com.openbravo.data.gui.TableRendererBasic;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.SerializerWriteBasic;
import com.openbravo.data.loader.StaticSentence;
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppProperties;
import com.openbravo.pos.forms.AppView;
import com.openbravo.pos.forms.BeanFactoryApp;
import com.openbravo.pos.forms.BeanFactoryException;
import com.openbravo.pos.forms.DataLogicSystem;
import com.openbravo.pos.forms.JPanelView;
import com.openbravo.pos.printer.TicketParser;
import com.openbravo.pos.printer.TicketPrinterException;
import com.openbravo.pos.scripting.ScriptEngine;
import com.openbravo.pos.scripting.ScriptException;
import com.openbravo.pos.scripting.ScriptFactory;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

public class JPanelCloseMoney extends JPanel
  implements JPanelView, BeanFactoryApp
{
  private AppView m_App;
  private DataLogicSystem m_dlSystem;
  private PaymentsModel m_PaymentsToClose = null;
  private TicketParser m_TTP;
  private JLabel jLabel1;
  private JLabel jLabel11;
  private JLabel jLabel12;
  private JLabel jLabel2;
  private JLabel jLabel3;
  private JLabel jLabel4;
  private JLabel jLabel5;
  private JLabel jLabel6;
  private JLabel jLabel7;
  private JPanel jPanel1;
  private JPanel jPanel4;
  private JPanel jPanel5;
  private JPanel jPanel6;
  private JTextField m_jCash;
  private JButton m_jCloseCash;
  private JTextField m_jCount;
  private JTextField m_jMaxDate;
  private JTextField m_jMinDate;
  private JButton m_jPrintCash;
  private JTextField m_jSales;
  private JTextField m_jSalesSubtotal;
  private JTextField m_jSalesTaxes;
  private JTextField m_jSalesTotal;
  private JScrollPane m_jScrollSales;
  private JScrollPane m_jScrollTableTicket;
  private JTextField m_jSequence;
  private JTable m_jTicketTable;
  private JTable m_jsalestable;
private MessageInf localMessageInf;

  public JPanelCloseMoney()
  {
    initComponents();
  }

  public void init(AppView paramAppView)
    throws BeanFactoryException
  {
    this.m_App = paramAppView;
    this.m_dlSystem = ((DataLogicSystem)this.m_App.getBean("com.openbravo.pos.forms.DataLogicSystem"));
    this.m_TTP = new TicketParser(this.m_App.getDeviceTicket(), this.m_dlSystem);
    this.m_jTicketTable.setDefaultRenderer(Object.class, new TableRendererBasic(new Formats[] { new FormatsPayment( ), Formats.CURRENCY }));
    this.m_jTicketTable.setAutoResizeMode(0);
    this.m_jScrollTableTicket.getVerticalScrollBar().setPreferredSize(new Dimension(25, 25));
    this.m_jTicketTable.getTableHeader().setReorderingAllowed(false);
    this.m_jTicketTable.setRowHeight(25);
    this.m_jTicketTable.getSelectionModel().setSelectionMode(0);
    this.m_jsalestable.setDefaultRenderer(Object.class, new TableRendererBasic(new Formats[] { Formats.STRING, Formats.CURRENCY, Formats.CURRENCY, Formats.CURRENCY }));
    this.m_jsalestable.setAutoResizeMode(0);
    this.m_jScrollSales.getVerticalScrollBar().setPreferredSize(new Dimension(25, 25));
    this.m_jsalestable.getTableHeader().setReorderingAllowed(false);
    this.m_jsalestable.setRowHeight(25);
    this.m_jsalestable.getSelectionModel().setSelectionMode(0);
  }

  public Object getBean()
  {
    return this;
  }

  public JComponent getComponent()
  {
    return this;
  }

  public String getTitle()
  {
    return AppLocal.getIntString("Menu.CloseTPV");
  }

  public void activate()
    throws BasicException
  {
    loadData();
  }

  public boolean deactivate()
  {
    return true;
  }

  private void loadData()
    throws BasicException
  {
    this.m_jSequence.setText(null);
    this.m_jMinDate.setText(null);
    this.m_jMaxDate.setText(null);
    this.m_jPrintCash.setEnabled(true); //ati to true
    this.m_jCloseCash.setEnabled(true);//ati to true
    this.m_jCount.setText(null);
    this.m_jCash.setText(null);
    this.m_jSales.setText(null);
    this.m_jSalesSubtotal.setText(null);
    this.m_jSalesTaxes.setText(null);
    this.m_jSalesTotal.setText(null);
    this.m_jTicketTable.setModel(new DefaultTableModel());
    this.m_jsalestable.setModel(new DefaultTableModel());
    this.m_PaymentsToClose = PaymentsModel.loadInstance(this.m_App);   //ATI add recomm add load
    this.m_jSequence.setText(this.m_PaymentsToClose.printSequence());
    this.m_jMinDate.setText(this.m_PaymentsToClose.printDateStart());
    this.m_jMaxDate.setText(this.m_PaymentsToClose.printDateEnd());
    if ((this.m_PaymentsToClose.getPayments() != 0) || (this.m_PaymentsToClose.getSales() != 0))
    {
      this.m_jPrintCash.setEnabled(true);
      this.m_jCloseCash.setEnabled(true);
      this.m_jCount.setText(this.m_PaymentsToClose.printPayments());
      this.m_jCash.setText(this.m_PaymentsToClose.printPaymentsTotal());
      this.m_jSales.setText(this.m_PaymentsToClose.printSales());
      this.m_jSalesSubtotal.setText(this.m_PaymentsToClose.printSalesBase());
      this.m_jSalesTaxes.setText(this.m_PaymentsToClose.printSalesTaxes());
      this.m_jSalesTotal.setText(this.m_PaymentsToClose.printSalesTotal());
    }
    this.m_jTicketTable.setModel(this.m_PaymentsToClose.getPaymentsModel());
    TableColumnModel localTableColumnModel = this.m_jTicketTable.getColumnModel();
    localTableColumnModel.getColumn(0).setPreferredWidth(200);
    localTableColumnModel.getColumn(0).setResizable(false);
    localTableColumnModel.getColumn(1).setPreferredWidth(100);
    localTableColumnModel.getColumn(1).setResizable(false);
    this.m_jsalestable.setModel(this.m_PaymentsToClose.getSalesModel());
    localTableColumnModel = this.m_jsalestable.getColumnModel();
    localTableColumnModel.getColumn(0).setPreferredWidth(200);
    localTableColumnModel.getColumn(0).setResizable(false);
    localTableColumnModel.getColumn(1).setPreferredWidth(100);
    localTableColumnModel.getColumn(1).setResizable(false);
  }

  private void printPayments(String paramString)
  {
    String str = this.m_dlSystem.getResourceAsXML(paramString);
    Object localObject;
    if (str == null)
    {
      localObject = new MessageInf(-33554432, AppLocal.getIntString("message.cannotprintticket"));
      ((MessageInf)localObject).show(this);
    }
    else
    {
      try
      {
        localObject = ScriptFactory.getScriptEngine("velocity");
        ((ScriptEngine)localObject).put("payments", this.m_PaymentsToClose);
        this.m_TTP.printTicket(((ScriptEngine)localObject).eval(str).toString());
      }
      catch (ScriptException localScriptException)
      {
        localMessageInf = new MessageInf(-33554432, AppLocal.getIntString("message.cannotprintticket"), localScriptException);
        localMessageInf.show(this);
      }
      catch (TicketPrinterException localTicketPrinterException)
      {
        MessageInf localMessageInf = new MessageInf(-33554432, AppLocal.getIntString("message.cannotprintticket"), localTicketPrinterException);
        localMessageInf.show(this);
      }
    }
  }

  private void initComponents()
  {
    this.jPanel1 = new JPanel();
    this.jPanel4 = new JPanel();
    this.jLabel11 = new JLabel();
    this.m_jSequence = new JTextField();
    this.jLabel2 = new JLabel();
    this.m_jMinDate = new JTextField();
    this.jLabel3 = new JLabel();
    this.m_jMaxDate = new JTextField();
    this.jPanel5 = new JPanel();
    this.m_jScrollTableTicket = new JScrollPane();
    this.m_jTicketTable = new JTable();
    this.jLabel1 = new JLabel();
    this.m_jCount = new JTextField();
    this.jLabel4 = new JLabel();
    this.m_jCash = new JTextField();
    this.jPanel6 = new JPanel();
    this.m_jSalesTotal = new JTextField();
    this.m_jScrollSales = new JScrollPane();
    this.m_jsalestable = new JTable();
    this.m_jSalesTaxes = new JTextField();
    this.m_jSalesSubtotal = new JTextField();
    this.m_jSales = new JTextField();
    this.jLabel5 = new JLabel();
    this.jLabel6 = new JLabel();
    this.jLabel12 = new JLabel();
    this.jLabel7 = new JLabel();
    this.m_jCloseCash = new JButton();
    this.m_jPrintCash = new JButton();
    setLayout(new BorderLayout());
    this.jPanel4.setBorder(BorderFactory.createTitledBorder(AppLocal.getIntString("label.datestitle")));
    this.jLabel11.setText(AppLocal.getIntString("label.sequence"));
    this.m_jSequence.setEditable(false);
    this.m_jSequence.setHorizontalAlignment(4);
    this.jLabel2.setText(AppLocal.getIntString("Label.StartDate"));
    this.m_jMinDate.setEditable(false);
    this.m_jMinDate.setHorizontalAlignment(4);
    this.jLabel3.setText(AppLocal.getIntString("Label.EndDate"));
    this.m_jMaxDate.setEditable(false);
    this.m_jMaxDate.setHorizontalAlignment(4);
    GroupLayout localGroupLayout1 = new GroupLayout(this.jPanel4);
    this.jPanel4.setLayout(localGroupLayout1);
    localGroupLayout1.setHorizontalGroup(localGroupLayout1.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout1.createSequentialGroup().addContainerGap().addGroup(localGroupLayout1.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout1.createSequentialGroup().addComponent(this.jLabel11, -2, 140, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jSequence, -2, 160, -2)).addGroup(localGroupLayout1.createSequentialGroup().addComponent(this.jLabel2, -2, 140, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jMinDate, -2, 160, -2)).addGroup(localGroupLayout1.createSequentialGroup().addComponent(this.jLabel3, -2, 140, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jMaxDate, -2, 160, -2))).addContainerGap(319, 32767)));
    localGroupLayout1.setVerticalGroup(localGroupLayout1.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout1.createSequentialGroup().addGroup(localGroupLayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel11).addComponent(this.m_jSequence, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel2).addComponent(this.m_jMinDate, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel3).addComponent(this.m_jMaxDate, -2, -1, -2)).addContainerGap(16, 32767)));
    this.jPanel5.setBorder(BorderFactory.createTitledBorder(AppLocal.getIntString("label.paymentstitle")));
    this.m_jScrollTableTicket.setMinimumSize(new Dimension(350, 140));
    this.m_jScrollTableTicket.setPreferredSize(new Dimension(350, 140));
    this.m_jTicketTable.setFocusable(false);
    this.m_jTicketTable.setIntercellSpacing(new Dimension(0, 1));
    this.m_jTicketTable.setRequestFocusEnabled(false);
    this.m_jTicketTable.setShowVerticalLines(false);
    this.m_jScrollTableTicket.setViewportView(this.m_jTicketTable);
    this.jLabel1.setText(AppLocal.getIntString("Label.Tickets"));
    this.m_jCount.setEditable(false);
    this.m_jCount.setHorizontalAlignment(4);
    this.jLabel4.setText(AppLocal.getIntString("Label.Cash"));
    this.m_jCash.setEditable(false);
    this.m_jCash.setHorizontalAlignment(4);
    GroupLayout localGroupLayout2 = new GroupLayout(this.jPanel5);
    this.jPanel5.setLayout(localGroupLayout2);
    localGroupLayout2.setHorizontalGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout2.createSequentialGroup().addContainerGap().addComponent(this.m_jScrollTableTicket, -2, 350, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout2.createSequentialGroup().addComponent(this.jLabel1, -2, 90, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jCount, -2, 100, -2)).addGroup(localGroupLayout2.createSequentialGroup().addComponent(this.jLabel4, -2, 90, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jCash, -2, 100, -2))).addContainerGap(67, 32767)));
    localGroupLayout2.setVerticalGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout2.createSequentialGroup().addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.m_jScrollTableTicket, -2, 140, -2).addGroup(localGroupLayout2.createSequentialGroup().addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel1).addComponent(this.m_jCount, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel4).addComponent(this.m_jCash, -2, -1, -2)))).addContainerGap(16, 32767)));
    this.jPanel6.setBorder(BorderFactory.createTitledBorder(AppLocal.getIntString("label.salestitle")));
    this.m_jSalesTotal.setEditable(false);
    this.m_jSalesTotal.setHorizontalAlignment(4);
    this.m_jsalestable.setFocusable(false);
    this.m_jsalestable.setIntercellSpacing(new Dimension(0, 1));
    this.m_jsalestable.setRequestFocusEnabled(false);
    this.m_jsalestable.setShowVerticalLines(false);
    this.m_jScrollSales.setViewportView(this.m_jsalestable);
    this.m_jSalesTaxes.setEditable(false);
    this.m_jSalesTaxes.setHorizontalAlignment(4);
    this.m_jSalesSubtotal.setEditable(false);
    this.m_jSalesSubtotal.setHorizontalAlignment(4);
    this.m_jSales.setEditable(false);
    this.m_jSales.setHorizontalAlignment(4);
    this.jLabel5.setText(AppLocal.getIntString("label.sales"));
    this.jLabel6.setText(AppLocal.getIntString("label.subtotalcash"));
    this.jLabel12.setText(AppLocal.getIntString("label.taxcash"));
    this.jLabel7.setText(AppLocal.getIntString("label.totalcash"));
    GroupLayout localGroupLayout3 = new GroupLayout(this.jPanel6);
    this.jPanel6.setLayout(localGroupLayout3);
    localGroupLayout3.setHorizontalGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout3.createSequentialGroup().addContainerGap().addComponent(this.m_jScrollSales, -2, 350, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout3.createSequentialGroup().addComponent(this.jLabel5, -2, 90, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jSales, -2, 100, -2)).addGroup(localGroupLayout3.createSequentialGroup().addComponent(this.jLabel6, -2, 90, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jSalesSubtotal, -2, 100, -2)).addGroup(localGroupLayout3.createSequentialGroup().addComponent(this.jLabel12, -2, 90, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jSalesTaxes, -2, 100, -2)).addGroup(localGroupLayout3.createSequentialGroup().addComponent(this.jLabel7, -2, 90, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jSalesTotal, -2, 100, -2))).addContainerGap(67, 32767)));
    localGroupLayout3.setVerticalGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout3.createSequentialGroup().addGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.m_jScrollSales, -2, 140, -2).addGroup(localGroupLayout3.createSequentialGroup().addGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel5).addComponent(this.m_jSales, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel6).addComponent(this.m_jSalesSubtotal, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel12).addComponent(this.m_jSalesTaxes, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel7).addComponent(this.m_jSalesTotal, -2, -1, -2)))).addContainerGap(16, 32767)));
    this.m_jCloseCash.setText(AppLocal.getIntString("Button.CloseCash"));
    this.m_jCloseCash.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JPanelCloseMoney.this.m_jCloseCashActionPerformed(paramActionEvent);
      }
    });
    this.m_jPrintCash.setText(AppLocal.getIntString("Button.PrintCash"));
    this.m_jPrintCash.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JPanelCloseMoney.this.m_jPrintCashActionPerformed(paramActionEvent);
      }
    });
    GroupLayout localGroupLayout4 = new GroupLayout(this.jPanel1);
    this.jPanel1.setLayout(localGroupLayout4);
    localGroupLayout4.setHorizontalGroup(localGroupLayout4.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout4.createSequentialGroup().addContainerGap().addGroup(localGroupLayout4.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, localGroupLayout4.createSequentialGroup().addComponent(this.m_jPrintCash).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jCloseCash)).addComponent(this.jPanel6, -1, -1, 32767).addComponent(this.jPanel4, -1, -1, 32767).addComponent(this.jPanel5, -1, -1, 32767)).addContainerGap()));
    localGroupLayout4.setVerticalGroup(localGroupLayout4.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout4.createSequentialGroup().addContainerGap().addComponent(this.jPanel4, -2, -1, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jPanel5, -2, -1, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jPanel6, -2, -1, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 31, 32767).addGroup(localGroupLayout4.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.m_jCloseCash).addComponent(this.m_jPrintCash)).addContainerGap()));
    add(this.jPanel1, "Center");
  }

  private void m_jCloseCashActionPerformed(ActionEvent paramActionEvent)
  {
    int i = JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.wannaclosecash"), AppLocal.getIntString("message.title"), 0, 3);
    if (i == 0)
    {
      Date localDate = new Date();
      MessageInf localMessageInf;
      try
      {
        if (this.m_App.getActiveCashDateEnd() == null) {
			String sql = "UPDATE CLOSEDCASH SET DATEEND = '@localDate@' WHERE HOST = '@host@' AND MONEY = '@money@'";
			new SqlFormatter().exe(sql,new HashMap ());
			//@@money is money_id act..
			sql=	sql.replace("@localDate@", timeUtil.Now_CST() ).replace("@host@", this.m_App.getProperties().getHost()).replace("@money@", this.m_App.getActiveCashIndex());
			System.out.println("----sql:: "+sql);
			//new Object[] {  this.m_App.getProperties().getHost(),  }
			new StaticSentence(this.m_App.getSession(), sql).exec();
		}
      }
      catch (BasicException localBasicException1)
      {
        localMessageInf = new MessageInf(-67108864, AppLocal.getIntString("message.cannotclosecash"), localBasicException1);
        localMessageInf.show(this);
      }
      try
      {
        this.m_App.setActiveCash(UUID.randomUUID().toString(), this.m_App.getActiveCashSequence() + 1, localDate, null);
     //   this.m_dlSystem.execInsertCash(new Object[] { this.m_App.getActiveCashIndex(), this.m_App.getProperties().getHost(), Integer.valueOf(this.m_App.getActiveCashSequence()), , this.m_App.getActiveCashDateEnd() });
      String sql="INSERT INTO CLOSEDCASH(MONEY, HOST, HOSTSEQUENCE, DATESTART, DATEEND) VALUES ('@MONEY@', '@HOST@',@HOSTSEQUENCE@,'@DATESTART@',@DATEEND@)";
  	sql=	sql.replace("@localDate@", timeUtil.Now_CST() ).replace("@HOST@", this.m_App.getProperties().getHost()).replace("@MONEY@", this.m_App.getActiveCashIndex());
  	sql=sql.replace("@HOSTSEQUENCE@", Integer.valueOf(this.m_App.getActiveCashSequence()).toString());
  	sql=sql.replace("@DATESTART@" ,DateUtil.toStandFmtYYYYmmDD_hhmmss_byDate_CST(this.m_App.getActiveCashDateStart())  );
  	sql=sql.replace("@DATEEND@",  SqlFormatter.toParamStrFmt(  DateUtil.toStandFmtYYYYmmDD_hhmmss_byDate_CST( this.m_App.getActiveCashDateEnd() ),"null"));
  	System.out.println(sql);
  //	this.m_App.getActiveCashDateStart()
  	new StaticSentence(this.m_App.getSession(), sql).exec();
  	
        this.m_PaymentsToClose.setDateEnd(localDate);
        printPayments("Printer.CloseCash");
        JOptionPane.showMessageDialog(this, AppLocal.getIntString("message.closecashok"), AppLocal.getIntString("message.title"), 1);
      }
      catch (BasicException localBasicException2)
      {
        localMessageInf = new MessageInf(-67108864, localBasicException2.getMessage(), localBasicException2);
        localMessageInf.show(this);
      }
      try
      {
        loadData();
      }
      catch (BasicException localBasicException3)
      {
        localMessageInf = new MessageInf(-67108864, AppLocal.getIntString("label.noticketstoclose"), localBasicException3);
        localMessageInf.show(this);
      }
    }
  }

  private void m_jPrintCashActionPerformed(ActionEvent paramActionEvent)
  {
    printPayments("Printer.PartialCash");
  }

  private class FormatsPayment extends Formats
  {
    private FormatsPayment()
    {
    }

    protected String formatValueInt(Object paramObject)
    {
      return AppLocal.getIntString("transpayment." + (String)paramObject);
    }

    protected Object parseValueInt(String paramString)
      throws ParseException
    {
      return paramString;
    }

    public int getAlignment()
    {
      return 2;
    }
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.panels.JPanelCloseMoney
 * JD-Core Version:    0.6.0
 */